home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / arm / gui / controller.py < prev    next >
Encoding:
Python Source  |  2012-05-18  |  1.6 KB  |  64 lines

  1. import thread
  2. import time
  3.  
  4. import gobject
  5. import gtk
  6.  
  7. from connections import connPanel
  8. from gui.graphing import bandwidthStats
  9. from gui import configPanel, generalPanel, logPanel
  10. from util import log, torTools
  11.  
  12. gobject.threads_init()
  13.  
  14. class GuiController:
  15.   def __init__(self):
  16.     self.builder = gtk.Builder()
  17.  
  18.     try:
  19.       self.builder.add_from_file('src/gui/arm.xml')
  20.     except:
  21.       # when installed the above path doesn't work (the 'src' prefix doesn't
  22.       # exist and whichever path it's working off of doens't seem to exist),
  23.       # so using absolute path instead
  24.  
  25.       self.builder.add_from_file('/usr/share/arm/gui/arm.xml')
  26.  
  27.     self.builder.connect_signals(self)
  28.  
  29.     panelClasses = (logPanel.LogPanel,
  30.               bandwidthStats.BandwidthStats,
  31.               connPanel.ConnectionPanel,
  32.               configPanel.ConfigPanel,
  33.               generalPanel.GeneralPanel)
  34.     self.panels = {}
  35.  
  36.     for panelClass in panelClasses:
  37.       self.panels[panelClass] = panelClass(self.builder)
  38.       self.panels[panelClass].pack_widgets()
  39.  
  40.   def run(self):
  41.     window = self.builder.get_object('window_main')
  42.  
  43.     window.show_all()
  44.     gtk.main()
  45.  
  46.   def on_action_about_activate(self, widget, data=None):
  47.     dialog = self.builder.get_object('aboutdialog')
  48.     dialog.run()
  49.  
  50.   def on_aboutdialog_response(self, widget, responseid, data=None):
  51.     dialog = self.builder.get_object('aboutdialog')
  52.     dialog.hide()
  53.  
  54.   def on_action_quit_activate(self, widget, data=None):
  55.     gtk.main_quit()
  56.  
  57.   def on_window_main_delete_event(self, widget, data=None):
  58.     gtk.main_quit()
  59.  
  60. def start_gui():
  61.   controller = GuiController()
  62.   controller.run()
  63.  
  64.